open Gmp

module Rand = 
        struct
                type frng = FltRng of float * float;;
                type irng = IntRng of int * int;;

                let floatRng = fun a b -> FltRng(a,b);;
                let intRng = fun a b -> IntRng(a,b);;
                let randInit = RNG.default;; 
                let getRandInt state = function
                        | IntRng(lo,hi) ->  
                                let boundary = hi-lo
                                in
                                let zboundary = Z.of_int boundary
                                in        
                                let c = Z.urandomm state zboundary
                                in
                                let res = Z.to_int c
                                in
                                res+lo
                let getRandFloat state = function
                        | FltRng(lo,hi) ->
                                let precision = 7
                                in
                                let b = F.urandomb state precision
                                in
                                let res = F.to_float b
                                in
                                res*.(hi-.lo)+.lo 

        end;;

